package com.boot.proofing.mpweb.base.entity;/**
 * @description
 * @autor xbwu on 2017/8/12.
 */


import com.baomidou.mybatisplus.annotation.*;
import com.boot.core.entity.BaseMpVersionEntity;
import com.boot.proofing.common.config.BaseConstant;
import com.boot.proofing.mpweb.base.entity.enums.SexEnums;
import com.boot.proofing.mpweb.base.entity.enums.UserTypeEnums;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import lombok.Data;


/**
 * 用户表
 *
 * @author xbwu
 * @create 2017-08-12
 **/
@TableName("t_user")
@Table(name = "t_user")
@Data
public class User extends BaseMpVersionEntity<User> {

    private static final long serialVersionUID = 4251816837394131331L;
    /**
     * 账号
     */
    @Column(name="account",isNull = false,type = MySqlTypeConstant.VARCHAR)
    private String account;

    /**
     * 名称 , condition 属性设置注入
     * 等效于 SQL 为：WHERE name LIKE CONCAT('%',s值,'%')
     */
    @Column(name="username",type = MySqlTypeConstant.VARCHAR)
    @TableField(condition = SqlCondition.LIKE)
    private String username;

    @Column(name="password",type = MySqlTypeConstant.VARCHAR)
    @JsonIgnore
    private String password;

    @TableField(value="user_type",fill = FieldFill.INSERT)
    @Column(name="user_type",type = MySqlTypeConstant.VARCHAR,length = 3)
    private UserTypeEnums userType;

    @Column(name="email",type = MySqlTypeConstant.VARCHAR)
    @TableField(condition = SqlCondition.LIKE)
    private String email;

    @Column(name="sex",type = MySqlTypeConstant.VARCHAR,length = 2)
    private SexEnums sex;

    @Column(name="phone",type = MySqlTypeConstant.VARCHAR,length = 25)
    @TableField(condition = SqlCondition.LIKE)
    private String phone;
    /**
     * 头像地址
     */
    @TableField(value="head_path",fill = FieldFill.INSERT)
    @Column(name="head_path",type = MySqlTypeConstant.VARCHAR,length = 100)
    private String headPath;

    /**
     * 逻辑删除字段,各MODEL自行斟酌是否要使用,具体值配置在application.yml中
     * 敏感数据可以使用，非敏感数据可以不配置，直接删除
     */
    @TableField(value="is_delete",fill = FieldFill.INSERT)
    @TableLogic
    @Column(name = "is_delete",type = MySqlTypeConstant.VARCHAR,isNull = false,length = 4)
    protected String isDelete;

    /**
     * 获取完整头像地址
     * @return
     */
    public String getFullHeadPath() {
        return BaseConstant.fileLocation+getHeadPath().replace(BaseConstant.nginxFilePrefix,"");
    }


}
